#pragma once

#include<sys/types.h>
#include<sys/stat.h>
#include<iostream>
#include<unistd.h>
#include<cstring>
#include<stdio.h>
#include<string>
#include<cerrno>
#include<stdlib.h>
#include<fcntl.h>

// 文件路径
#define FIFO_FILE "./myfifo"  // 查????
#define MODE 0664

enum{
    FIFO_CREAT_ERR = 1,
    FIFO_DELETE_ERR = 2,
    FIFO_OPEN_ERR = 3
};

class Init
{
public:
    Init()
    {
        int n = mkfifo(FIFO_FILE,MODE);
        if(n==-1)
        {
            perror("mkfifo");
            exit(FIFO_CREAT_ERR);
        }
    }
    ~Init()
    {
    
        int m = unlink(FIFO_FILE);
        if(m == -1)//删除失败
        {
            perror("unlink");
            exit(FIFO_DELETE_ERR);
        }
    }
};